package test;

import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.sound.midi.ControllerEventListener;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MetaEventListener;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.Synthesizer;
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;

public class MidiSelectOutputDevice {
	public static void main(String[] args) throws Exception {
//		MidiDevice dev = MidiSystem.getMidiDevice(MidiSystem.getMidiDeviceInfo()[3]);
//		Sequencer seq = MidiSystem.getSequencer(false);
//		File file;
//		seq.setSequence(MidiSystem.getSequence(file = new File("midifiles/new.mid")));
//		seq.getTransmitter().setReceiver(dev.getReceiver());
//		dev.open();
//		seq.open();
//		seq.start();
//		Thread.sleep(10000);
//		seq.close();
//		dev.close();
		
		MidiDevice dev = MidiSystem.getMidiDevice(MidiSystem.getMidiDeviceInfo()[3]);
		dev.open();
		Sequencer seq = MidiSystem.getSequencer(false);
		seq.setSequence(MidiSystem.getSequence(new File("midifiles/new.mid")));
		seq.getTransmitter().setReceiver(dev.getReceiver());
		seq.open();
		seq.start();
		Thread.sleep(10000);
		dev.close();
	}
}
